/*
    This file is part of open-wars <http://code.google.com/p/open-wars/>.

    open-wars is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    open-wars is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with open-wars.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef ui_interface_h
#define ui_interface_h

#include <list>
#include <boost/any.hpp>

#include <common-datatypes.h>
#include <renderer-interface.h>
#include <input-interface.h>

namespace MouseType
{
    typedef enum 
    {
        Arrow,              // Standard arrow
        Busy,               // Busy (when input is not possible)
        Help,               // Standard arrow with help indicator
        Pointer,            // Pointer arrow (typically a hand, typically used when hovering over links)
        Move,               // 4-directional move indicator
        Precision,          // Cross-hair style cursor
        ResizeULBR,         // Resize indicator for upper-left to lower-right
        ResizeBLUR,         // Resize indicator for bottom-left to upper-right
        ResizeHorizontal,   // Resize indicator for horizontal (left to right)
        ResizeVertical,     // Resize indicator for vertical (top to bottom)
        Text,               // Indicates text input
        Unavailable,        // Used to show when a cursor action is not possible (typically a 'no' sign)
        BackgroundWork      // Indicates that input is possible, but the system is also busy
    } Type;
}

namespace MouseAnimation
{
    typedef enum 
    {
        Static, // Single mouse image, no animation
        Loop,   // Animated mouse. Plays from start to end, then repeats
        Bounce, // Animated mouse. Plays from start to end, then backwards back to start.
    } Type;
}

typedef struct
{
    MouseAnimation::Type animationType;
    MouseType::Type mouseType;
    std::list<TEXTURE> textures;
    std::list<TEXTURE>::iterator curFrame;
    bool reverse;
    bool init;
    int tickCount;
    int ticksPerFrame;
} InputInterfaceMouse;


typedef void(*IUIInterfaceCallback)(boost::any);

class UIWidget;

class UILabel
{
	public:
		STRING caption;
		float x, y;
		int r, g, b, a;
		BOOLEAN visible;
};

class IUIInterface
{

	public:
		virtual ~IUIInterface() {};
		
		// Rendering Functions
		virtual void SetRenderer		(IRendererInterface *renderer)	{ };
        virtual void SetInputInterface  (IInputInterface *iface)        { inputInterface = iface; };
		virtual void Render				()								{ };
		
		// Widgets Functions
		virtual void AddWidget			(UIWidget *widget)				{ };
		virtual void RemoveWidget		(UIWidget *widget)				{ };
		virtual void RemoveAllWidgets	(void)							{ };
		
		// Cursor Functions
        virtual void AddInterfaceMouse      (InputInterfaceMouse m)     { interfaceMouse.push_back(m); interfaceMouse.back().init = true; };
        virtual void SetCurrentMouse        (MouseType::Type type)      { currentMouseType = type; };

        IInputInterface *inputInterface;
        MouseType::Type currentMouseType;
        std::list<InputInterfaceMouse> interfaceMouse;

};

#endif // ui_interface_h
